/**
 * Created by Qingger Corp.
 * User: jsspf
 * Date: 2018/1/2
 * Time: 16:11
 */
import {Context} from "koa";
import {midLogger} from "./src/middleware/logger";
import {appRouter} from "./src/router/index";

const Koa = require("koa");
const app = new Koa();
const Router = require("koa-router");

const homeRouter = new Router();
homeRouter.get('/',function(ctx:Context,next:Function) {
    ctx.body = '<ul><li>page/helloword</li><li>404 Not found</li></ul>';
});

homeRouter.get('/home', function(ctx:Context,next:Function){
    ctx.body = "<div>HOME PAGE</div>";
});


app.use(midLogger());
// app.use(homeRouter.routes()).use(homeRouter.allowedMethods());
app.use(appRouter.routes(),appRouter.allowedMethods());

app.use(async (ctx:Context) => {
    ctx.body = "hello koa2";
});

app.listen(3000);
console.log("[demo] start-quick is starting at port 3000");
